package com.example.controller;

import com.alibaba.fastjson.JSONObject;
import com.example.annotations.Auth;
import com.example.annotations.RestController;
import com.example.annotations.UploadFile;
import com.example.model.UploadBody;
import com.example.model.UploadModel;
import com.example.utils.Results;

import java.util.List;

/**
 * @Classname FileController
 * @Description TODO
 * @Date 2022/8/4 15:43
 * @Created by XiongXiong
 * @Author: X.I.O
 */
@RestController("/startfile")
public class RestFileController {


    @UploadFile(value = "/upload",size = 10000000)
    public JSONObject uploadFileController(UploadBody uploadBody){
        return Results.success(uploadBody);
    }


    @Auth
    @UploadFile(value = "/toupolad",size = 100000000,desc = "文件上传")
    public JSONObject touploadFileController(UploadBody uploadBody){

        if(uploadBody!=null && uploadBody.getUploadModels()!=null){
            List<UploadModel> uploadModels=uploadBody.getUploadModels();
            for (UploadModel uploadModel : uploadModels) {
                System.out.println(uploadModel.getPath());
                System.out.println(uploadModel.getContentType());
            }
        }
        return Results.success(uploadBody);
    }

}
